﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SystemCenterSoa.DtoModel.Common;
using SystemCenterSoa.DtoModel.SystemManager;
using SystemCenterSoa.IRepository.SystemManager;
using SystemCenterSoa.PoModel.SystemManager;

namespace SystemCenterSoa.Service.SystemManager
{
    public class RoleService : BaseService
    {
        private IRoleRepository _roleRepository;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="iModuleDbDal">注入的dal</param>

        public RoleService(IRoleRepository roleRepository)
        {
            _roleRepository = roleRepository;
        }
        public RoleDto GetRoleViewById(int roleId)
        {
            return _roleRepository.GetRoleViewById(roleId);
        }
        /// <summary>
        /// 查询指定用户名下面的角色
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public List<RolePo> GetRoleDbsByUserName(string userName)
        {
            return _roleRepository.GetRoleDbsByUserName(userName);
        }
        public PagerResult<RolePo> SearchPage(SearchModel searchModel)
        {
            return _roleRepository.SearchPage(searchModel);
        }
        /// <summary>
        /// 角色添加
        /// </summary>
        /// <param name="view">角色视图</param>
        /// <returns></returns>
        public int RoleDbAdd(RoleDto view)
        {
            view.creator_date = DateTime.Now;
            view.creator_name = "lzh";
            return _roleRepository.RoleDbAdd(view);
        }

        public bool RoleUpdate(RoleDto view)
        {
            view.modifi_date = DateTime.Now;
            view.modifi_name = "lzh";
            return _roleRepository.RoleUpdate(view);
        }
    }
}
